package o;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.huawei.hmf.annotation.ActivityDefine;

public class fjf<T> {
    private String ˊ;
    private T ˋ;
    private fjl<T> ˎ;

    private fjf(Activity activity) {
        this.ˊ = new fjg(activity.getIntent()).ˏ();
        Class result = ((ActivityDefine) activity.getClass().getAnnotation(ActivityDefine.class)).result();
        if (result.isInterface()) {
            this.ˎ = new fjl(result);
            this.ˋ = this.ˎ.get();
            return;
        }
        try {
            this.ˋ = result.newInstance();
        } catch (Exception e) {
        }
    }

    private fjf(Intent intent) {
        if (intent != null) {
            fjn ˎ = fjn.ˎ(intent);
            this.ˊ = ˎ.ˎ("__ResultClassname__");
            if (this.ˊ != null) {
                try {
                    Object o_fjl;
                    Class cls = Class.forName(this.ˊ);
                    if (cls.isInterface()) {
                        o_fjl = new fjl(cls);
                    } else {
                        o_fjl = cls.newInstance();
                    }
                    new fib().ˏ(ˎ.ˋ("__Result__"), o_fjl);
                    if (o_fjl instanceof fjl) {
                        this.ˋ = ((fjl) o_fjl).get();
                    } else {
                        this.ˋ = o_fjl;
                    }
                } catch (Throwable e) {
                    Log.e("ActivityResult", "Instancing ActivityResult exception.", e);
                }
            }
        }
    }

    public T ॱ() {
        return this.ˋ;
    }

    public Intent ˊ() {
        Intent intent = new Intent();
        if (this.ˋ == null) {
            return intent;
        }
        Object obj = this.ˎ == null ? this.ˋ : this.ˎ;
        intent.putExtra("__ResultClassname__", this.ˊ);
        intent.putExtra("__Result__", new fib().ˋ(obj, new Bundle()));
        return intent;
    }

    public static <R> fjf<R> ˊ(Activity activity) {
        return new fjf(activity);
    }

    public static <R> fjf<R> ˋ(Intent intent) {
        return new fjf(intent);
    }
}
